//题目连接：https://www.acwing.com/problem/content/855/
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 510 , K = N , M = 10010;
int dis[N] , backup[N];
int n , m , k;
struct
{
    int a , b , w;
}edges[M];

int bellman_ford()
{
    memset(dis,0x3f,sizeof dis);
    dis[1] = 0;
    for(int i = 0 ; i < k ; ++i)
    {
        memcpy(backup,dis,sizeof dis);
        for(int j = 0 ; j < m ; ++j)
        {
            int a = edges[j].a , b = edges[j].b , w = edges[j].w;
            dis[b] = min(dis[b],backup[a] + w);
        }
    }
    return dis[n];
}

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i = 0 ; i < m ; ++i)
    {
        int a , b , w;
        scanf("%d%d%d",&a,&b,&w);
        edges[i] = {a,b,w};
    }
    int t = bellman_ford();
    if(t > 0x3f3f3f3f / 2) printf("impossible\n");
    else printf("%d ",t);
    return 0;
}